<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>统计</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="../static/css/bootstrap.min.css" th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/>
    <link href="../static/css/font-awesome.min.css" th:href="@{/css/font-awesome.min.css}" rel="stylesheet"/>
    <link href="../static/css/animate.min.css" th:href="@{/css/animate.min.css}" rel="stylesheet"/>
    <link href="../static/css/style.min.css" th:href="@{/css/style.min.css}" rel="stylesheet"/>
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content">

        <div class="row">
            <div class="col-sm-4">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <span class="label label-success pull-right">今日新增</span>
                        <h5>用户</h5>
                    </div>
                    <div class="ibox-content">
                        <h1 class="no-margins" th:text="${'+ '+userTodayNum}">+ 40</h1>
                        <div class="stat-percent font-bold text-success">比昨日<span th:text="${userCompare}"></span>
                        </div>
                        <small th:text="${'总数：'+userTotal}">总数： 886,200</small>
                    </div>
                </div>
            </div>
            <div class="col-sm-4">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <span class="label label-info pull-right">今日新增</span>
                        <h5>任务</h5>
                    </div>
                    <div class="ibox-content">
                        <h1 class="no-margins" th:text="${'+ '+taskTodayNum}">+ 80</h1>
                        <div class="stat-percent font-bold text-info">比昨日<span th:text="${taskCompare}"></span>
                        </div>
                        <small th:text="${'总数：'+taskTotal}">总数： 886,200</small>
                    </div>
                </div>
            </div>
            <div class="col-sm-4">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <span class="label label-primary pull-right">今日新增</span>
                        <h5>帖子</h5>
                    </div>
                    <div class="ibox-content">
                        <h1 class="no-margins" th:text="${'+ '+articleTodayNum}">+ 106,120</h1>
                        <div class="stat-percent font-bold text-navy">比昨日<span th:text="${articleCompare}"></span>
                        </div>
                        <small th:text="${'总数：'+articleTotal}">总数：886,200</small>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>Error 日志</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <table class="table table-hover no-margins">
                            <thead>
                                <tr>
                                    <th>日志编号</th>
                                    <th>系统模块</th>
                                    <th>操作类型</th>
                                    <th>操作用户</th>
                                    <th>主机</th>
                                    <th>日志级别</th>
                                    <th>操作时间</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody id="log-box">

                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
         </div>
      </div>
    </div>
    <th:block th:include="include :: footer-index"/>
    <script th:src="@{/ajax/libs/flot/jquery.flot.js}"></script>
    <th:block th:include="include :: sparkline-js" />
    <script th:inline="javascript">
        var flow = layui.flow;
        var util = layui.util;
        //日志加载
        flow.load({
            elem: '#log-box' //指定列表容器
            ,done: function(page, next){ //到达临界点（默认滚动触发），触发下一页
                var lis = [];
                //以jQuery的Ajax请求为例，请求下一页数据（注意：page是从2开始返回）
                var url = "/monitor/operlog/list";
                var data={
                    pageSize: 10,
                    pageNum: page,
                    isAsc: 'desc',
                    orderByColumn:'oper_time',
                    status:'1'
                    // isDesc:'desc'
                }
                var config = {
                    url: url,
                    type: "post",
                    dataType: "json",
                    data: data,
                    beforeSend: function () {

                    },
                    success: function(result) {
                        if (result.code===0){
                            //假设你的列表返回在data集合中
                            layui.each(result.rows, function(index, item){
                                var businessType = item.businessType;
                                if (businessType==1){
                                    businessType='新增'
                                } else if (businessType==2){
                                    businessType='修改'
                                }else if (businessType==3){
                                    businessType='删除'
                                }else {
                                    businessType='其他'
                                }
                                lis.push('<tr>\n' +
                                    '    <td>'+item.operId+'</td>\n' +
                                    '    <td>'+item.title+'</td>\n' +
                                    '    <td>'+businessType+'</td>\n' +
                                    '    <td class="text-navy">'+item.operName+'</td>\n' +
                                    '    <td>'+item.operIp+'</td>\n' +
                                    '    <td>error</td>\n' +
                                    '    <td><i class="fa fa-clock-o"></i> '+item.operTime+'</td>\n' +
                                    '    <td class="text-navy"><a href="javascript:;" onclick="gotLogDetails('+item.operId+')">查看详情</a></td>\n' +
                                    '</tr>     ')
                            });
                            //执行下一页渲染，第二参数为：满足“加载更多”的条件，即后面仍有分页
                            //pages为Ajax返回的总页数，只有当前页小于总页数的情况下，才会继续出现加载更多
                            next(lis.join(''), page < result.total/10);
                        }else {
                            layer.open({
                                title: '系统提示'
                                ,content: '加载失败，请稍后再试！！！'
                                ,yes: function(){
                                    layer.closeAll();
                                }
                            });
                        }
                    }
                };
                $.ajax(config)
            }
        });
        function gotLogDetails(id) {
            var url = '/monitor/operlog/detail/'+id;
            top.layer.open({
                type : 2,
                title : '日志详情',
                anim : 2,
                area : [ '70%', '70%' ],
                maxmin : true,
                shadeClose: true,
                content : url
            })
        }
    </script>
</body>
</html>
